package com.hd.sup.modules.alarm.wrapper;

import com.google.common.collect.Lists;
import com.hd.common.constant.BizConstant;
import com.hd.common.page.BaseControllerWrapper;
import com.hd.common.utils.DateUtil;
import org.apache.commons.lang3.StringUtils;
import org.assertj.core.util.Sets;

import java.util.*;

/**
 * @author chentl
 * @version V1.0
 * @Project 交通运输第三方监测平台
 * @Title AlarmWrapper.java
 * @Description 报警规则装饰器
 * @Package com.hd.sup.modules.alarm.wrapper
 * @date 2020/12/31 2:48 下午
 * @Copyright: 深圳市宏电技术股份有限公司 All rights reserved.
 */
public class AlarmRuleWrapper extends BaseControllerWrapper {

    public AlarmRuleWrapper(Object obj) {
        super(obj);
    }

    @Override
    protected void warpTheMap(Map<String, Object> map) {
        //报警开始时间
        Object trans_type = map.get("trans_type");
        if (trans_type != null) {
            String transTypes = (String) trans_type;
            //映射合并规则
            List<String> ts = Arrays.asList(transTypes.split(BizConstant.Common.SEPARATOR.key()));
            Set<String> nts = Sets.newHashSet();
            ts.forEach(one -> {
                if (BizConstant.VehicleTransType.PASSENGER.key().equals(one) || BizConstant.VehicleTransType.TRAVEL.key().equals(one)) {
                    nts.add(BizConstant.RuleTransType.PASSENGER.key());
                } else if (BizConstant.VehicleTransType.DANGER.key().equals(one)) {
                    nts.add(BizConstant.RuleTransType.DANGER.key());
                } else if (BizConstant.VehicleTransType.FREIGHT.key().equals(one)) {
                    nts.add(BizConstant.RuleTransType.FREIGHT.key());
                }

            });

            map.put("trans_type", StringUtils.join(nts, BizConstant.Common.SEPARATOR.key()));
        }

    }
}